
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        添加药剂师信息
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <style>
        .imgs{display: none;}
    </style>

</head>
<body>
<div class="x-body">
    <form class="layui-form layui-form-pane" action="" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">

                    <input type="hidden" name="id" value="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>用户名
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="userName" autocomplete="off" placeholder="用户名"
                                   class="layui-input" required="" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>密码
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="password" autocomplete="off" placeholder="密码"
                                   class="layui-input" required="" lay-verify="required" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>真实姓名
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="realName" autocomplete="off" placeholder="真实姓名"
                                   class="layui-input"  value="">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button class="layui-btn" type="button" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                    <div style="height:100px;"></div>
                </div>

            </div>

        </div>
    </form>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function(data) {
            var username = $("input[name='userName']").val();
            var password = $("input[name='password']").val();
            var realName = $("input[name='realName']").val();
            if (username === "") {
                layer.msg('用户名不能为空！', {icon: 5, time: 2000});
                return false;
            }
            if (password === "") {
                layer.msg('密码不能为空！', {icon: 5, time: 2000});
                return false;
            }
            if (realName === "") {
                layer.msg('姓名不能为空！', {icon: 5, time: 2000});
                return false;
            }
            var fm = data.field;
            $.ajax({
                async:false,
                type:"post",
                url:"/pharmaceutist/addPharmaceutist",
                data:fm,
                error: function (){
                    alert("添加错误")
                },
                success:function(res)
                {
                    if(res.state === 200) {
                        alert("添加成功，请刷新页面")
                    }
                }
            });
            this.load("/index.html")
        });
    })
</script>

</body>
</html>